package shuashuami.hb.com.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.List;

import shuashuami.hb.com.hbclient.R;
import shuashuami.hb.com.model.EmpiricalValue;

public class CEmpiricalValueAdapter extends BaseAdapter {
    private LayoutInflater inflater;
    private List<EmpiricalValue> list;
    private Context con;

    public CEmpiricalValueAdapter(List<EmpiricalValue> list, Context context) {
        this.con = context;
        inflater = LayoutInflater.from(context);
        this.list = list;
    }

    @Override
    public int getCount() {
        if (null != list) {
            return list.size();
        } else {
            return 0;
        }
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        EmpiricalValueViewHoler viewHolder;
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.adapter_c_emirical_value_layout, null);
            viewHolder = new EmpiricalValueViewHoler();
            viewHolder.tvTitle = (TextView) convertView.findViewById(R.id.tv_c_emirical_value_title);
            viewHolder.tvDate = (TextView) convertView.findViewById(R.id.tv_c_emirical_value_date);
            viewHolder.tvEmpiricalValue = (TextView) convertView.findViewById(R.id.tv_c_emirical_value_num);

            convertView.setTag(viewHolder);
        } else {
            viewHolder = (EmpiricalValueViewHoler) convertView.getTag();
        }
        EmpiricalValue content = list.get(position);
        viewHolder.tvDate.setText(content.getDate());
        viewHolder.tvTitle.setText(content.getTitle());
        viewHolder.tvEmpiricalValue.setText(content.getEmpiricalValue());
        return convertView;
    }

    class EmpiricalValueViewHoler {
        public TextView tvTitle;
        public TextView tvDate;
        public TextView tvEmpiricalValue;
    }


}




